{include file="index/meta" /}
{load href="/static/css/wangeditor.css" /}
<div class="el-dialog__body">
 <!--顶部-->
     <form method="post" onsubmit="return post_add(this,'{:url('edit')}')">   
  <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">标题</label>
    <div class="col-sm-10">
      <input type="text" name="title" value="{$find.title}" class="form-control" placeholder="请输入标题">
    </div>
  </div>
  
    <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">选择栏目</label>
    <div class="col-sm-10">
      <select class="form-select" name="catid" aria-label="选择栏目">
          {volist name="cate" id="vo"}
          <option value="{$vo.id}" {if $find.catid == $vo.id}selected{/if}>{$vo.catname}</option>
          {/volist}
        </select>
    </div>
  </div>
  
    <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">关键词</label>
    <div class="col-sm-10">
      <input type="text" name="keywords" value="{$find.keywords}" class="form-control" placeholder="请输入关键词">
    </div>
  </div>
  
    
    <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">描述</label>
    <div class="col-sm-10">
      <textarea type="text" name="description"  rows="5" class="form-control" placeholder="请输入描述">{$find.description}</textarea>
    </div>
  </div>
  
    
    <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">发布时间</label>
    <div class="col-sm-10">
      <input type="text" name="inputtime" id="inputtime" value="{:date("Y-m-d H:i:s",$find.inputtime)}" class="form-control" placeholder="请输入发布时间">
    </div>
  </div>
  
    
    <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">阅读权限</label>
    <div class="col-sm-10">
      <select class="form-select" name="groupids_view" aria-label="选择阅读权限">
          <option value="0">无权限</option>
          {volist name='group' id='vo'} 
          <option value="{$vo.groupid}" {if $find.groupids_view == $vo.groupid}selected{/if}>{$vo.name}</option>
          {/volist}
        </select>
    </div>
  </div>
  
    
    <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">阅读收费</label>
    <div class="col-sm-10 input-group mb-3" style="width: 83.33333333%;">
      <input type="number" name="readpoint" value="{$find.readpoint}" class="form-control" placeholder="请输入阅读收费">
      
        <div class="form-check form-check-inline" style="margin: auto 1rem;">
  <input class="form-check-input" type="radio" name="paytype" value="1" id="inlineRadio1" {if $find.paytype ==1}checked=""{/if}>
  <label class="form-check-label" for="inlineRadio1">积分</label>
</div>
<div class="form-check form-check-inline"  style="margin: auto 1rem;">
  <input class="form-check-input" type="radio" name="paytype" value="2" id="inlineRadio2" {if $find.paytype ==2}checked=""{/if}>
  <label class="form-check-label" for="inlineRadio2">金钱</label>
</div>
        
    </div>
  </div>
  
  
      <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">缩略图</label>
    <div class="col-sm-10 input-group mb-3" style="width: 83.33333333%;">
              <input type="text" id="thumb" name="thumb" value="{$find.thumb}" class="form-control" placeholder="请输入选择图像">
               <button onclick="qh_open('图片管理','{:url('attachment/add',['name'=>'thumb'])}',700,500)" class="el-button el-button--primary" type="button">上传</button>
            </div>
  </div>
  
  
      <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">来源</label>
    <div class="col-sm-10">
      <input type="text" name="copyfrom" value="{$find.copyfrom}" class="form-control" placeholder="请输入来源">
    </div>
  </div>
  
  
  
      <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">点击</label>
    <div class="col-sm-10">
      <input type="text" name="click" value="{$find.click}" class="form-control" placeholder="请输入点击">
    </div>
  </div>
  
  
      <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">昵称</label>
    <div class="col-sm-10">
      <input type="text" name="nickname" value="{$find.nickname}" class="form-control" placeholder="请输入昵称">
    </div>
  </div>
  
      <div class="mb-3 row">
    <label  class="col-sm-2 col-form-label">内容</label>
    <div class="col-sm-10">
     <div id="editor—wrapper" style="border: var(--bs-border-width) solid var(--bs-border-color);">
     <div id="editor-toolbar" class="editor-toolbar"></div>
    <div id="editor-text-area" class="editor-text-area"></div>
       <textarea type="text" id="editor-content-textarea" name="content" style="display: none;">{$find.content|raw}</textarea>
    </div>
  </div>
  <input type="hidden" name="__token__" value="{:token()}" />
  <input type="hidden" name="id" value="{$find.id}" />
  <!--底部-->
    <footer class="el-dialog__footer">
        <span class="dialog-footer">
            <button  type="button" class="el-button el-button--danger" data-bs-dismiss="modal" aria-label="Close">
                <span class="">取消</span></button>
            <button class="el-button el-button--primary" aria-disabled="false" type="submit">
                <span class="">确认</span></button>
        </span>
    </footer>
    </form>

</div>
<script>
layui.use(function(){
  var laydate = layui.laydate;
  // 日期时间选择器 - 日期和时间选择器同时显示（全面板）
  laydate.render({
    elem: '#inputtime',
    type: 'datetime',
   });
 });
</script>
{load href="/static/js/wangeditor.js" /} 
{include file="index/footer" /}
<script>
const E = window.wangEditor

    // Change language
    const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN'
    E.i18nChangeLanguage(LANG)
    
    const editorConfig = { 
        onChange(editor) {
      const html = editor.getHtml()
       document.getElementById('editor-content-textarea').value = html
    },
        MENU_CONF: {} }
    editorConfig.MENU_CONF['uploadImage'] = {
      server: '{:url('admin/attachment/upload_content')}',
      timeout: 5 * 1000, // 5s
      fieldName: 'file',
      meta: { token: 'xxx', a: 100 },
      metaWithUrl: true, // join params to url
      headers: { Accept: 'text/x-json' },
       maxFileSize: 10 * 1024 * 1024, // 10M
       base64LimitSize: 5 * 1024, // insert base64 format, if file's size less than 5kb
       onBeforeUpload(file) {
        console.log('onBeforeUpload', file)
        return file // will upload this file
        // return false // prevent upload
      },
      onProgress(progress) {
        console.log('onProgress', progress)
      },
      onSuccess(file, res) {
        console.log('onSuccess', file, res)
      },
      onFailed(file, res) {
        alert(res.message)
        console.log('onFailed', file, res)
      },
      onError(file, err, res) {
        alert(err.message)
        console.error('onError', file, err, res)
      },
     

    }

    const editor = E.createEditor({
      selector: '#editor-text-area',
      html: $("#editor-content-textarea").val(),
      config: editorConfig
    })

    const toolbar = E.createToolbar({
      editor,
      selector: '#editor-toolbar',
      // config: {}
    })

</script>
<style>
    body{background: #fff;min-width: auto;}
    #editor—wrapper {z-index: 10000000; /* 按需定义 */}#editor-text-area { height: 400px; }
</style>
